package com.ktmall.controller;

import com.ktmall.pojo.GoodsItem;
import com.ktmall.service.GoodsItemService;
import com.ktmall.utils.RespMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "商品详情相关接口")
@RestController
@RequestMapping("/uni/home/goods")
public class LoadGoodsDetailController {
    @Autowired
    private GoodsItemService goodsItemService;

    @ApiOperation("查询用户选中的商品详情")
    @RequestMapping("/findById")
    public RespMsg findById(Integer id){
        RespMsg msg = null;
        if(id != null){
            //1.调用service中的方法实现根据商品id加载商品详情
            GoodsItem goods = goodsItemService.findById(id);
            msg = RespMsg.success("商品详情加载成功",goods);
        }else{
            msg = RespMsg.fail("商品id不能为空");
        }
        return msg;
    }
}
